package cn.qiao.web.util;

import jakarta.servlet.ServletRequest;

public class RequestUtil {

    private static final String LOCALHOST_IP_V6 = "0:0:0:0:0:0:0:1";
    private static final String LOCALHOST_IP_V4 = "127.0.0.1";

    public static String getRemoteAddr(ServletRequest servletRequest) {
        String remoteAddr = servletRequest.getRemoteAddr();
        return LOCALHOST_IP_V6.equals(remoteAddr) ? LOCALHOST_IP_V4 : remoteAddr;
    }
}
